package _interview100;

/**
 * 169. 多数元素
 */
public class No169 {
    public int majorityElement(int[] nums) {
        int ans = Integer.MIN_VALUE;
        int count = 0;
        for (int num : nums) {
            if (count == 0) ans = num;
            count += num == ans ? 1 : -1;
        }
        return ans;
    }
}
